//
//  BDJMeViewController.m
//  BuDeJie
//
//  Created by Guo Rui on 2017/9/19.
//  Copyright © 2017年 GR Harry. All rights reserved.
//

#import "BDJMeViewController.h"
#import "UIBarButtonItem+item.h"
#import "BDJSettingViewController.h"

@interface BDJMeViewController ()

@end

@implementation BDJMeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupNavBar];
    
    if (@available(iOS 11, *)) {
        self.tableView.separatorInset = UIEdgeInsetsZero;
        self.tableView.separatorInsetReference = UITableViewSeparatorInsetFromCellEdges;
    }
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tabBarDidRepeatClick) name:BDJTabBarButtonDidRepeatClickNotification object:nil];
    
}

- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    NSLog(@"\n************\n %@ dealloc \n************", self.class);
}

- (void)tabBarDidRepeatClick
{
    // 点击的不是精华分栏不应该响应
    if (!self.view.window) return;
    
    BDJFUNC
}

- (void)setupNavBar
{
    UIBarButtonItem *settingItem = [UIBarButtonItem itemWithImage:[UIImage imageNamed:@"mine-setting-icon"] highlightImage:[UIImage imageNamed:@"mine-setting-icon-click"] target:self action:@selector(setting)];
    UIBarButtonItem *themeItem = [UIBarButtonItem itemWithImage:[UIImage imageNamed:@"mine-moon-icon"] selImage:[UIImage imageNamed:@"mine-moon-icon-click"] target:self action:@selector(theme:)];
    
    self.navigationItem.rightBarButtonItems = @[ settingItem, themeItem ];
    self.navigationItem.title = @"我";
}

- (void)setting
{
    BDJSettingViewController *settingVc = [[BDJSettingViewController alloc] init];
    settingVc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:settingVc animated:YES];
}

- (void)theme:(UIButton *)btn
{
    btn.selected = !btn.selected;
}

@end
